import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import router from './router'
import App from './App.vue'
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/reset.css'
import './assets/styles/global.css'
import dayjs from 'dayjs'

const app = createApp(App)

const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)

app.use(pinia)
app.use(Antd)
app.use(router)
app.mount('#app')

// 添加全局方法
app.config.globalProperties.$formatDate = (date: string | Date, format = 'YYYY-MM-DD HH:mm:ss') => {
  //如果没有传date，则返回空字符串
  if (!date) {
    return null
  }
  return dayjs(date).format(format)
}
